package com.luyuan.crm.user.web.provider;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.faces.model.SelectItem;

import org.springframework.stereotype.Component;

import com.luyuan.crm.user.Party;
import com.luyuan.crm.user.service.PartyService;
import com.ruijie.web.jsf.provider.SelectItemsProvider;

@Component("supportPartyProvider")
public class SupportPartyProvider implements SelectItemsProvider {

    @Resource(name = "partyService")
    private PartyService partyService;

    @Override
    public List<SelectItem> getSelectItems(Object... parameters) {
        List<Party> parties = partyService.findByRoleName(new String[] { "售后经理", "售后" });

        List<SelectItem> items = new ArrayList<SelectItem>();
        for (Party party : parties) {
            SelectItem item = new SelectItem(party, party.getUserName());
            items.add(item);
        }
        return items;
    }
}
